﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_BBS_DeleteCatalog]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_BBS_DeleteCatalog];
GO
CREATE PROCEDURE [dbo].[sproc_BBS_DeleteCatalog]
    @catalog_id int
/*
====================================================
功能:    删除版块
参数:
    @catalog_id int        :    版块ID
====================================================

*/
AS
SET NOCOUNT ON
--删除回复
DELETE FROM uds_bbs_replay
    WHERE item_id IN
    (SELECT item_id FROM uds_bbs_forumitem
        WHERE board_id IN 
        (SELECT board_id
            FROM uds_bbs_board 
            WHERE catalog_id= @catalog_id
        )
    )
--删除帖子
DELETE FROM uds_bbs_forumitem
    WHERE board_id IN 
    (SELECT board_id
        FROM uds_bbs_board 
        WHERE catalog_id= @catalog_id
    )
--删除斑竹
DELETE FROM uds_bbs_boardmaster
    WHERE board_id IN
    (SELECT board_id
        FROM uds_bbs_board
        WHERE catalog_id= @catalog_id
    )
--删除板块
DELETE FROM uds_bbs_board 
    WHERE board_id IN 
    (SELECT board_id
        FROM uds_bbs_board 
        WHERE catalog_id= @catalog_id
    )
--删除分类栏
DELETE FROM uds_bbs_catalog 
    WHERE catalog_id= @catalog_id